package com.flx.cloud.shop.admin.service.impl;

import com.flx.cloud.shop.admin.entity.Employee;
import com.flx.cloud.shop.admin.mapper.EmployeeMapper;
import com.flx.cloud.shop.admin.service.EmployeeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Service;

/**
* @author Administrator
* @description 针对表【t_employee】的数据库操作Service实现
* @createDate 2022-05-03 19:01:36
*/
@Slf4j
@Service
@RefreshScope //配置实时更新
public class EmployeeServiceImpl implements EmployeeService {

    @Value("${nacos.author:default}")
    public String author;

    @Autowired
    private EmployeeMapper employeeMapper;

    public Employee get(Long id)throws Exception{
        return employeeMapper.selectById(id);
    }

    public int add(Employee user)throws Exception{
        return employeeMapper.insert(user);
    }

    public int update(Employee user)throws Exception{
        return employeeMapper.updateById(user);
    }

    public int delete(Long id)throws Exception{
        return employeeMapper.deleteById(id);
    }

    public String getAuthor()throws Exception{
        log.info("from nacos getAuthor = {}",author);
        return author;
    }

}




